<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('products', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('entity_id')->default(0)->index()->comment('实体对象ID');
            $table->boolean('type')->default(0)->comment('类型：1酒店套餐');
            $table->string('name')->default('')->comment('套餐名称');
            $table->string('thumbnail')->default('')->comment('封面');
            $table->decimal('price', 10, 2)->default(0)->comment('价格');
            $table->unsignedInteger('sort')->default(0)->comment('排序');
            $table->boolean('is_enable')->default(0)->comment('是否上架：1是 0否');
            $table->boolean('is_delete')->default(0)->comment('是否删除：1是 0否');
            $table->dateTime('created_at')->default(\DB::raw('CURRENT_TIMESTAMP'));
            $table->timestamp('updated_at')->default(\DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
        });
        DB::statement("ALTER TABLE `products` COMMENT '套餐'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
         if (!is_production()) Schema::dropIfExists('products');
    }
};
